package com.ruoyi.web.controller.fx;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.fx.FxOrderDada;
import com.ruoyi.system.service.fx.IFxOrderDadaService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 达达配送订单记录Controller
 *
 * @author ruoyi
 * @date 2025-03-27
 */
@RestController
@RequestMapping("/system/dada")
public class FxOrderDadaController extends BaseController
{
    @Autowired
    private IFxOrderDadaService fxOrderDadaService;

    /**
     * 查询达达配送订单记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dada:list')")
    @GetMapping("/list")
    public TableDataInfo list(FxOrderDada fxOrderDada)
    {
        startPage();
        List<FxOrderDada> list = fxOrderDadaService.selectFxOrderDadaList(fxOrderDada);
        return getDataTable(list);
    }

    /**
     * 导出达达配送订单记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:dada:export')")
    @Log(title = "达达配送订单记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FxOrderDada fxOrderDada)
    {
        List<FxOrderDada> list = fxOrderDadaService.selectFxOrderDadaList(fxOrderDada);
        ExcelUtil<FxOrderDada> util = new ExcelUtil<FxOrderDada>(FxOrderDada.class);
        util.exportExcel(response, list, "达达配送订单记录数据");
    }

    /**
     * 获取达达配送订单记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dada:query')")
    @GetMapping(value = "/{orderId}")
    public AjaxResult getInfo(@PathVariable("orderId") String orderId)
    {
        return success(fxOrderDadaService.selectFxOrderDadaByOrderId(orderId));
    }

    /**
     * 新增达达配送订单记录
     */
    @PreAuthorize("@ss.hasPermi('system:dada:add')")
    @Log(title = "达达配送订单记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FxOrderDada fxOrderDada)
    {
        return toAjax(fxOrderDadaService.insertFxOrderDada(fxOrderDada));
    }

    /**
     * 修改达达配送订单记录
     */
    @PreAuthorize("@ss.hasPermi('system:dada:edit')")
    @Log(title = "达达配送订单记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FxOrderDada fxOrderDada)
    {
        return toAjax(fxOrderDadaService.updateFxOrderDada(fxOrderDada));
    }

    /**
     * 删除达达配送订单记录
     */
    @PreAuthorize("@ss.hasPermi('system:dada:remove')")
    @Log(title = "达达配送订单记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{orderIds}")
    public AjaxResult remove(@PathVariable String[] orderIds)
    {
        return toAjax(fxOrderDadaService.deleteFxOrderDadaByOrderIds(orderIds));
    }
}
